package cn.edu.neusoft.yuejian13.yuejian_13.fragment;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;

import java.util.List;

import cn.edu.neusoft.yuejian13.yuejian_13.R;
import cn.edu.neusoft.yuejian13.yuejian_13.adapter.ClubListAdapter;
import cn.edu.neusoft.yuejian13.yuejian_13.javaBean.Club;
import cn.edu.neusoft.yuejian13.yuejian_13.listener.List_TListener;
import cn.edu.neusoft.yuejian13.yuejian_13.model.ClubModel;



public class ClubFragment extends Fragment implements View.OnClickListener {

    private View view;
    private Button lv1,lv2,lv3;
    private RecyclerView recyclerView;


    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        view = inflater.inflate(R.layout.fragment_club,container,false);
        initViews();
        initEvent();
        ClubModel clubModel = new ClubModel();
        clubModel.allClub(allclub);
        return view;

    }

  List_TListener<Club> allclub = new List_TListener<Club>() {
      @Override
      public void onResponse(List<Club> list) {
          ClubListAdapter clubListAdapter = new ClubListAdapter(getContext(),list);
          recyclerView.setAdapter(clubListAdapter);
      }

      @Override
      public void onFail(String msg) {

      }
  };

    private void initEvent() {
        lv1.setOnClickListener(this);
        lv2.setOnClickListener(this);
        lv3.setOnClickListener(this);

    }

    private void initViews() {
        recyclerView = (RecyclerView)view.findViewById(R.id.rv_club);
        LinearLayoutManager layoutManager = new LinearLayoutManager(this.getActivity());
        layoutManager.setOrientation(LinearLayoutManager.VERTICAL);
        recyclerView.setLayoutManager(layoutManager);
        lv1 = (Button) view.findViewById(R.id.club_nor);
        lv2 = (Button) view.findViewById(R.id.club_renqi);
        lv3 = (Button)view.findViewById(R.id.club_rec);

    }



    @Override
    public void onClick(View v) {
        ClubModel clubModel = new ClubModel();
        switch (v.getId()){
            case R.id.club_nor:
                clubModel.allClub(allclub);
                break;
            case R.id.club_renqi:
                break;
            case R.id.club_rec:
                break;

        }
    }
}
